/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.corticon.dialogs.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.validator.Email;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotEmpty;
import org.hibernate.validator.Pattern;


/**
 * 
 * @author Yanglifan
 */
@Entity
@Table(name = "qs_usergroup")
public class UserGroup extends AuditableEntity implements Serializable {

    private String name;
    private String description;
    private String contactName;
    private String contactEmail;
    private String contactPhone;

    public UserGroup() {
    }

    public UserGroup(String name) {
        this.name = name;
    }

    @Length(max = 30, message = "UserGroup.name.length.invalid")
    @NotEmpty(message = "validate.group.name.notempty")
    @Id
    @Column(name = "groupid", length = 30)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Length(max = 255, message = "UserGroup.description.length.invalid")
    @NotEmpty(message = "userGroup.validate.description.required")
    @Column(name = "description", nullable = false)
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Length(max = 255, message = "UserGroup.contactName.length.invalid")
    @NotEmpty(message = "validate.group.contactName.required")
    @Column(name = "contact_name")
    public String getContactName() {
        return contactName;
    }

    public void setContactName(String contactName) {
        this.contactName = contactName;
    }

    @Length(max = 255, message = "UserGroup.contactEmail.length.invalid")
    @NotEmpty(message = "validate.group.contactEmail.required")
    @Email(message = "validate.email")
    @Column(name = "contact_email")
    public String getContactEmail() {
        return contactEmail;
    }

    public void setContactEmail(String contactEmail) {
        this.contactEmail = contactEmail;
    }

    @NotEmpty(message = "validate.group.contactPhone.required")
    @Pattern(regex = "\\d{3}-\\d{3}-\\d{4}", message = "validate.group.contactPhone.notMatched")
    @Column(name = "contact_phone")
    public String getContactPhone() {
        return contactPhone;
    }

    public void setContactPhone(String contactPhone) {
        this.contactPhone = contactPhone;
    }

    @Override
    public String toString() {
        return "usergroup ('" + getName() + "')";
    }
}
